﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test JSON in Javascript</title>
    <link rel="stylesheet" type="text/css" href="../common/qunit.css" />
    <script type="text/javascript" src="../common/jquery.js"></script>
    <script type="text/javascript" src="../common/qunit.js"></script>
    <script type="text/javascript">

        function demoAPI() {
            var original = { x: 1, y: 2 };

            var text = JSON.stringify(original);
            equal(text, '{"x":1,"y":2}');

            var copy = JSON.parse(text);
            deepEqual(original, copy);
        }

        function demoOnlySerializeOwnProperties() {

            var a = { x: 1, y: 2 };
            equal(JSON.stringify(a), '{"x":1,"y":2}');

            var b = Object.create(a);
            equal(JSON.stringify(b), '{"x":1,"y":2}');
        }

    </script>
</head>
<body>
    <h1 id="qunit-header">
        JSON Demonstration</h1>
    <h2 id="qunit-banner">
    </h2>
    <div id="qunit-testrunner-toolbar">
    </div>
    <h2 id="qunit-userAgent">
    </h2>
    <ol id="qunit-tests">
    </ol>
    <div id="qunit-fixture">
        test markup, will be hidden</div>
    <script type="text/javascript">
        test("demo the usage of API", demoAPI);
        test("only serialize own properties, inherited properties NOT include", demoOnlySerializeOwnProperties);
    </script>
</body>
</html>
